package com.spring.annotation;

import com.spring.beans.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 *  @Lazy  主要应用于但实例对象singleton
 *         容器启动时候不创建对象，而是使用时候创建
 */
@Configuration
public class LazyConfig {

    @Bean
    @Lazy
    public User user(){
        System.out.println("实例化user对象。。。。。");
        User user = new User("za", 23);
        return user;
    }
}
